#include "BinaryTree.h"
#include"Queue.h"
void PrevOrder(BTNode* root)
{
	if (root == NULL)
	{
		return;
	}
	printf("%c ", root->data);
	PrevOrder(root->left);
	PrevOrder(root->right);
}
void mediumOrder(BTNode* root)
{
	if (root == NULL)
	{
		return;
	}
	
	mediumOrder(root->left);
	printf("%c ", root->data);
	mediumOrder(root->right);
}
void BackOrder(BTNode* root)
{
	if (root == NULL)
	{
		return;
	}
	
	BackOrder(root->left);
	BackOrder(root->right);
	printf("%c ", root->data); 
}

int TreeSize(BTNode* root)
{
	return root == NULL ? 0 : TreeSize(root->left) + TreeSize(root->right) + 1;
}

int TreeleafSize(BTNode* root)
{
	if (root == NULL)
	{
		return 0;
	}
	return root->left == NULL && root->right == NULL ? 1 : TreeleafSize(root->left) + TreeleafSize(root->right);
}
void layerOrder(BTNode* root)
{
	Queue q;
	if (root == NULL)
	{
		return;
	}
	QueueInit(&q);
	QueuePush(&q, root);
	while (!QueueIsEmpty(&q))
	{
		BTNode* front=QueueFront(&q);
		printf("%c ", front->data);
		QueuePop(&q);
		if (front->left)
		{
			QueuePush(&q, front->left);
		}
		if (front->right)
		{
			QueuePush(&q, front->right);
		}
	}
	QueueDestroy(&q);
}